#-*- coding:utf-8 -*-
import tensorflow as tf
import os
from glob import glob
from ldr2hdr_loader import LDR2HDR_Loader

class LDR2HDR(object):

    def __init__(self, sess=None):
        self.im_height = 64
        self.im_width = 128
        self.batch_size = 128
        self.sess = sess
        if self.sess is None:
            self.sess = tf.Session(config=tf.ConfigProto(log_device_placement=False))

        self.model_path = './model'

        self.fname_model = self._locateModel(self.model_path)
        self._load()

    def _locateModel(self, path):
        matafiles = glob(os.path.join(path, '*.meta'))
        return matafiles[-1]

    def _load(self):
        '''load the model with TF backend'''
        self.model = LDR2HDR_Loader(self.sess)
        self.model.load_tf_model(self.fname_model)


ldr2hdr = LDR2HDR()
